#ifndef RADIATION_SOURCE_STATE_MACHINE__LIFECYCLE_NODE_CLIENT_HPP_
#define RADIATION_SOURCE_STATE_MACHINE__LIFECYCLE_NODE_CLIENT_HPP_

#include <rclcpp/rclcpp.hpp>
#include <rclcpp_lifecycle/lifecycle_node.hpp>
#include <lifecycle_msgs/srv/change_state.hpp>
#include <lifecycle_msgs/srv/get_state.hpp>
#include <lifecycle_msgs/msg/state.hpp>
#include <memory>
#include <string>
#include <chrono>
#include <thread>


namespace radiation_source_state_machine
{

class LifecycleNodeClient
{
public:
    explicit LifecycleNodeClient(
        rclcpp::Node::SharedPtr parent_node,
        const std::string& node_name);

    bool configure();
    bool activate();
    bool deactivate();
    bool cleanup();

    lifecycle_msgs::msg::State get_current_state();
    bool wait_for_state(lifecycle_msgs::msg::State::LifecycleState state, 
                       std::chrono::milliseconds timeout = std::chrono::seconds(5));
    bool is_active() const;

private:
    rclcpp::Node::SharedPtr parent_node_;
    std::string node_name_;
    rclcpp::Client<lifecycle_msgs::srv::ChangeState>::SharedPtr change_state_client_;
    rclcpp::Client<lifecycle_msgs::srv::GetState>::SharedPtr get_state_client_;
    lifecycle_msgs::msg::State current_state_;
    bool is_client_initialized_;
};

}  // namespace radiation_source_state_machine

#endif  // RADIATION_SOURCE_STATE_MACHINE__LIFECYCLE_NODE_CLIENT_HPP_